import { Code, CreateDate, DateTime, Digdit, Int, Jsonb, Money, PrimaryUuid, UpdateDate } from "../utils";
import { Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity({
    name: 'auto_device_work'
})
export class AutoDeviceWork {
    @PrimaryGeneratedColumn()
    id: number;

    @Digdit({ default: 0 })
    room: number;

    @Digdit({ default: 0 })
    red: number;

    @Money({ default: 0 })
    money: number;

    @Digdit({ default: 0 })
    success: number;

    @Digdit({ default: 0 })
    fail: number;

    @Digdit({ default: 100 })
    mood: number;

    @Digdit({ default: 0 })
    continuous_fail: number;

    @Digdit({ default: 0 })
    continuous_success: number;

    @Digdit({ default: 0 })
    continuous_room_fail: number;

    @Digdit({ default: 0 })
    continuous_room_success: number;

    @Code({ default: '' })
    pre: string;

    @Code({ default: `` })
    from: string;

    @Code()
    date: string;

    @UpdateDate()
    udpate_date: Date;

    @Code()
    uuid: string;

    @CreateDate()
    create_date: Date;

    @Code({ default: `0`, comment: `设备状态` })
    status: string;

    @Code({ default: `worker`, comment: '机器类型' })
    type: string;

}

@Entity({
    name: 'auto_device'
})
export class AutoDevice {
    @PrimaryUuid()
    id: string;

    @Int()
    uid: number;

    @Code()
    device_uuid: string;

    @Code()
    device_name: string;

    @CreateDate()
    create_date: Date;

    @Code()
    token: string;

    @Code({ default: '0' })
    status: string;

    @Code({ default: 'worker' })
    type: string;

    @DateTime({ nullable: true })
    ping_time: Date;

    @Jsonb({ comment: '设备设置', default: {} })
    settings: any;

    @Money({ default: 0, comment: '设备收益' })
    total_money: number;

    @Digdit({ default: 0 })
    red_count: number;

    @Jsonb({ comment: '设备应用', default: [] })
    apps: string[];

}
